import {observable, action} from 'mobx';
import { WeaLocaleProvider } from 'ecCom';
import singleRowImg from '../../img/singleRow.png'
import doubleRowImg from '../../img/doubleRow.png'
import progressTypeImg from '../../img/progressType.png'
import avatarTypeImg from '../../img/avatarType.png'

const getLabel = WeaLocaleProvider.getLabel;

export default class Store {
    @observable
    nodata = <div className="nodata">{getLabel(83553, '暂无数据')}</div>

    @observable
    noright = <div className="noright">{getLabel(509275,"您的系统未开启任务管理模块")}</div>

    @observable
    defaultCurrSettingItemData = {
        orderbyTransferDatas: [
            {
                id: 1,
                orderType: "",
                name: getLabel(30436, "创建时间")
            },
            {
                id: 2,
                orderType: "",
                name: getLabel(500371, "开始时间")
            },
            {
                id: 3,
                orderType: "",
                name: getLabel(500372, "结束时间")
            },
            {
                id: 4,
                orderType: "",
                name: getLabel(16936, "责任人")
            },
            {
                id: 5,
                orderType: "",
                name: getLabel(882, '创建人')
            },
            {
                id: 6,
                orderType: "",
                name: getLabel('517605','进度') 
            }
        ],
        fieldshowTransferDatas: [
            {
                id: 1,
                fieldname: "name",
                name: getLabel('33439', '名称'),
                proportion: 10,
                // maxWidth: 240
            },
            {
                id: 2,
                fieldname: "taskprogress",
                name: getLabel('517605','进度')  ,
                proportion: 5,
                maxWidth: 200,
            },
            {
                id: 3,
                fieldname: "status",
                name: getLabel(23247, '状态'),
                proportion: 2,
                maxWidth: 80
            },
            {
                id: 4,
                fieldname: "principalid",
                name: getLabel(16936, "责任人"),
                proportion: 2,
                maxWidth: 80
            },
            {
                id: 5,
                fieldname: "creater",
                name: getLabel(882, '创建人'),
                proportion: 2,
                maxWidth: 80
            },
            {
                id: 6,
                fieldname: "begindate",
                name: getLabel(500371, "开始时间"),
                proportion: 3,
                maxWidth: 120
            },
            {
                id: 7,
                fieldname: "enddate",
                name: getLabel(500372, "结束时间"),
                proportion: 3,
                maxWidth: 120
            }
        ],
        paginate: 0,
        pagesize: 5,
        fieldshow: "name,principalid,status,enddate",
        displayType: "1",
        status:"0",
        showAvator: "principal"
    }

    @observable
    condtypeOptions = [
        {
            key: "0",
            selected: false,
            showname: getLabel(81834, '所有任务')
        },{
            key: "1",
            selected: false,
            showname: getLabel(19865, '我的任务')
        },{
            key: "2",
            selected: false,
            showname: getLabel(382485, '我创建的任务')
        },{
            key: "3",
            selected: false,
            showname: getLabel(382482, '我负责的任务')
        },{
            key: "4",
            selected: false,
            showname: getLabel(382483, '我参与的任务')
        },{
            key: "5",
            selected: false,
            showname: getLabel(382492, '分享给我的任务')
        },{
            key: "6",
            selected: false,
            showname: getLabel(382484, '我关注的任务')
        },{
            key: "7",
            selected: false,
            showname: getLabel(508743, '已完成新反馈的任务')
        },{
            key: "8",
            selected: false,
            showname: getLabel(382486, '我分配的任务')
        },
        {
            key: "9",
            selected: false,
            showname: getLabel(508734,'下属任务')
        }
    ]

    @observable
    subordinateTypeOptions = [
        {
            key: "0",         
            selected: false,
            showname: getLabel(515498, "直接下属")
        },{
            key: "1",         
            selected: false,
            showname: getLabel(17494, "所有下属")
        }
    ]

    @observable
    statusOptions = [
        {
            key: "0",
            selected: false,
            showname: getLabel(332,'全部')
        },{
            key: "1",
            selected: false,
            showname: getLabel(1960, '进行中')
        },{
            key: "2",
            selected: false,
            showname: getLabel(23774, '已完成')
        }
    ]

    @observable
    urgent = [
        {
            key: "",
            selected: false,
            showname: ""
        },
        {
            key: "0",
            selected: false,
            showname: getLabel(15808, '未设置')
        },{
            key: "1",
            selected: false,
            showname: getLabel(382501, '重要紧急')
        },{
            key: "2",
            selected: false,
            showname: getLabel(382502, '重要不紧急')
        },{
            key: "3",
            selected: false,
            showname: getLabel(382503, '不重要紧急') 
        },{
            key: "4",
            selected: false,
            showname: getLabel(382504, '不重要不紧急')
        }
    ]

    @action
    getUrgentShownameByKey = (key) => {
        let keyIndex = this.urgent.map((d, i) => d.key).indexOf(key)
        return keyIndex !== -1 ? this.urgent[keyIndex].showname : ""
    }

    @observable
    displayTypeOptions = [
        {
            key: "1",
            showname: (
                <div
                    title={getLabel('517607', '单行列表')} 
                    className="portal-task-element-display-type-option"
                    ref={ref => {
                        if (ref) {
                            ref.parentNode.setAttribute("title", "")
                        }
                    }}
                >
                    <img src={singleRowImg} width={30} height={20} className="img-wrapper" />
                    <span className="text-wrapper">
                        {getLabel('517607', '单行列表')}
                    </span>
                </div>
            )
        },
        {
            key: "2",
            showname: (
                <div 
                    title={getLabel('517578', '双行列表')} 
                    className="portal-task-element-display-type-option"
                    ref={ref => {
                        if (ref) {
                            ref.parentNode.setAttribute("title", "")
                        }
                    }}
                >
                    <img src={doubleRowImg} width={30} height={20} className="img-wrapper" />
                    <span className="text-wrapper">
                        {getLabel('517578', '双行列表')}
                    </span>
                </div>
            )
        },
        {
            key: "3",
            showname: (
                <div 
                    title={getLabel('517575', '进度式') } 
                    className="portal-task-element-display-type-option"
                    ref={ref => {
                        if (ref) {
                            ref.parentNode.setAttribute("title", "")
                        }
                    }}
                >
                    <img src={progressTypeImg} width={30} height={20} className="img-wrapper" />
                    <span className="text-wrapper">
                        {getLabel('517575', '进度式') }
                    </span>
                </div>
            )
        },
        {
            key: "4",
            showname: (
                <div 
                    title={getLabel('517606', '头像式') } 
                    className="portal-task-element-display-type-option"
                    ref={ref => {
                        if (ref) {
                            ref.parentNode.setAttribute("title", "")
                        }
                    }}
                >
                    <img src={avatarTypeImg} width={30} height={20} className="img-wrapper" />
                    <span className="text-wrapper">
                        {getLabel('517606', '头像式') }
                    </span>
                </div>
            )
        }
    ]
}